package main

import (
	"github.com/nsqio/go-nsq"
	"net"
	"fmt"
	"time"
)

func main() {
	fmt.Println( t1() )
}

func t1() error {
	config := nsq.NewConfig()
	laddr := "127.0.0.1"

	config.LocalAddr, _ = net.ResolveTCPAddr("tcp", laddr+":0")
	producer , err := nsq.NewProducer("127.0.0.1:4150" ,config)

	if err != nil {
		return err
	}

	err = producer.Publish("test" , []byte("t :" + time.Now().String() ))
	err = producer.Publish("test" , []byte("t :" + time.Now().String() ))
	err = producer.Publish("test" , []byte("t :" + time.Now().String() ))
	err = producer.Publish("test" , []byte("t :" + time.Now().String() ))

	if err != nil {
		
	}
	producer.Stop()
	
	return nil
}
